package com.lsl.factory_kit;

import com.lsl.factory_kit.factory.WeaponFactory;
import com.lsl.factory_kit.weapon.*;
import com.lsl.factory_kit.weapontype.WeaponType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;

/**
 * @author Zed
 * @description
 * @date 2023/1/8 21:37
 */
public class App {
    private static final Logger logger = LoggerFactory.getLogger(com.lsl.factory_method.example2.method.App.class);

    public static void main(String[] args) {
        var factory = WeaponFactory.factory(builder -> {
            builder.add(WeaponType.SWORD, Sword::new);
            builder.add(WeaponType.AXE, Axe::new);
            builder.add(WeaponType.SPEAR, Spear::new);
            builder.add(WeaponType.BOW, Bow::new);
        });
        var list = new ArrayList<Weapon>();
        list.add(factory.create(WeaponType.AXE));
        list.add(factory.create(WeaponType.SPEAR));
        list.add(factory.create(WeaponType.SWORD));
        list.add(factory.create(WeaponType.BOW));
        list.forEach(weapon -> logger.info("{}", weapon.toString()));
    }
}

